<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page session="false" %>
<html>
<head>
<title>Admin</title>
<link rel="stylesheet" href="<c:url value="/resources/css/backend.css" />" type="text/css">
<link href="<c:url value="/resources/syntaxhighlighter/styles/shCoreEclipse.css" />" rel="stylesheet" type="text/css" />
<style type="text/css">
.syntaxhighlighter { overflow-y: hidden !important; }
</style>
<script type="text/javascript" src="<c:url value="/resources/javascript/jquery-1.6.1.js" />"></script>
<script type="text/javascript" src="<c:url value="/resources/syntaxhighlighter/scripts/shCore.js" />"></script>
<script type="text/javascript" src="<c:url value="/resources/syntaxhighlighter/scripts/shAutoloader.js" />"></script>
</head>

<script type="text/javascript">
$(document).ready(function() {
	SyntaxHighlighter.autoloader(
	    'applescript            /resources/syntaxhighlighter/scripts/shBrushAppleScript.js',
	    'actionscript3 as3      /resources/syntaxhighlighter/scripts/shBrushAS3.js',
	    'bash shell             /resources/syntaxhighlighter/scripts/shBrushBash.js',
	    'coldfusion cf          /resources/syntaxhighlighter/scripts/shBrushColdFusion.js',
	    'cpp c                  /resources/syntaxhighlighter/scripts/shBrushCpp.js',
	    'c# c-sharp csharp      /resources/syntaxhighlighter/scripts/shBrushCSharp.js',
	    'css                    /resources/syntaxhighlighter/scripts/shBrushCss.js',
	    'delphi pascal          /resources/syntaxhighlighter/scripts/shBrushDelphi.js',
	    'diff patch pas         /resources/syntaxhighlighter/scripts/shBrushDiff.js',
	    'erl erlang             /resources/syntaxhighlighter/scripts/shBrushErlang.js',
	    'groovy                 /resources/syntaxhighlighter/scripts/shBrushGroovy.js',
	    'java                   /resources/syntaxhighlighter/scripts/shBrushJava.js',
	    'jfx javafx             /resources/syntaxhighlighter/scripts/shBrushJavaFX.js',
	    'js jscript javascript  /resources/syntaxhighlighter/scripts/shBrushJScript.js',
	    'perl pl                /resources/syntaxhighlighter/scripts/shBrushPerl.js',
	    'php                    /resources/syntaxhighlighter/scripts/shBrushPhp.js',
	    'text plain             /resources/syntaxhighlighter/scripts/shBrushPlain.js',
	    'py python              /resources/syntaxhighlighter/scripts/shBrushPython.js',
	    'ruby rails ror rb      /resources/syntaxhighlighter/scripts/shBrushRuby.js',
	    'sass scss              /resources/syntaxhighlighter/scripts/shBrushSass.js',
	    'scala                  /resources/syntaxhighlighter/scripts/shBrushScala.js',
	    'sql                    /resources/syntaxhighlighter/scripts/shBrushSql.js',
	    'vb vbnet               /resources/syntaxhighlighter/scripts/shBrushVb.js',
	    'xml xhtml xslt html    /resources/syntaxhighlighter/scripts/shBrushXml.js'  
	);
	SyntaxHighlighter.all();  

	$(".del-comment-link").live('click', function(){
		var link = $(this);
		$.ajax({type: "DELETE", url: '<c:url value="/admin/comments/"/>' +  link.attr('name'),
	    data: {}, contentType: "application/json", dataType: "text",
	    success: function(text) { 
	      alert(text + ": the comment was deleted!");
	      var liId =  "#" + link.attr('name');
	      $(liId).remove();
	    }, 
	    error: function(xhr) { alert("Comment deletion fails!" + xhr.responseText); }
	   });		
	});	
});
</script>

<body>
<div class="wrapper">

<div class="header">
  <h1>iBun Admin Console</h1>
</div>

<div class="content">
  <div class="left-sider">
    <jsp:include page="../templates/adminMenu.jsp"></jsp:include>    
  </div>

  <div class="main">
 
    <div class="blog-div">
      <div class="blog-title-div">
        <div class="blog-title">
          <a class="blog-title-link" href="#">${blog.title}</a>
        </div>   
        <hr class="separator"/> 
        <div class="blog-info">
          <fmt:formatDate pattern="yyyy-MM-dd hh:mm:ss" value="${blog.createTime}" /> | 
          categorized in <a href="<c:url value="/blogs/category/${blog.categoryKey}"/>">${blog.categoryKey}</a> |
          tagged in 
          <c:forEach items="${blog.tags}" var="tag">
            <a href="<c:url value="/blogs/tag/${tag}"/>">${tag}</a> 
          </c:forEach>
          <a class="blog-comment-link" href="<c:url value="/blogs/${blog.id}"/>#comments">comments(${blog.commentCount})</a>
        </div>   
      </div>
      <div class="blog-content">
        ${blog.content} 
      </div>
    </div>
    
    <a href="/blogs/${blog.id}">Normal View</a>

    <div class="comment-list-div">
      <h3 class="sub-title">Comments</h3>
      <p class="sub-link"><a name="comments"></a></p>
      
      <ul id="comment-list">
        <c:forEach items="${blog.comments}" var="comment">
          <li class="comment-entry" id="${comment.encodedKey}">
            <img class="avatar" src="${comment.avatarLink}" height="64" width="64">
            <div class="triangle-left"></div>
            <div class="comment-info">
              <div class="comment-meta">
                <fmt:formatDate pattern="yyyy-MM-dd hh:mm:ss" value="${comment.createTime}" />
              </div>
              <div class="comment-author">
                <c:if test="${ not empty comment.publisherWebsite}">
                  <a href="${comment.publisherWebsite}">${comment.publisherName}</a> says:
                </c:if>
                <c:if test="${ empty comment.publisherWebsite}">
                  ${comment.publisherName} says:
                </c:if>
              </div>
              <div class="comment-content">
                <p>${comment.content}</p>
              </div>
            </div>
            <div class="comment-admin-options">
              <a class="del-comment-link" name="${comment.encodedKey}" href="#">delete</a>
            </div>
          </li>
        </c:forEach>
      </ul>
    </div>
   
  </div>
</div>

<div class="footer">
</div>

</div>
</body>
</html>